Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add negative sizes as a prop pack #528

Open
wants to merge 6 commits into
base: 2.0.0beta
Choose a base branch
from

Conversation

felix-bohlin
Copy link

@felix-bohlin felix-bohlin commented Dec 3, 2024

Not sure if I nailed the naming of stuff, you might want to take a look at that.

Worth noting also is that I reversed the values in each clamp and switched to logical units, ie:

--size-fluid-1: clamp(0.5rem, 1vw, 1rem); /* positive */
--size-fluid-1-: clamp(-1rem, -1vi, -0.5rem); /* negative */

Copy link

stackblitz bot commented Dec 3, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Owner

@argyleink argyleink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the use case for these? do they actually produce usable values?

curious if we should instead just

--size-fluid-1-: calc(var(--size-fluid-1) * -1);

this produces the inverted value too?

@felix-bohlin
Copy link
Author

felix-bohlin commented Dec 18, 2024

Are you questioning the point of negative fluid sizes specifically or all of them?

Fluid is probably a more contrived situation but my thought process there was that
a) my lack of imagination how these primitives should be used shouldn't stop others from doing it
b) it wouldn't "burden" the core lib since it would be a prop pack

With that said, there's no rush here. More code is more technical debt and once you release something it's hard to take it back.

Regarding your proposition with calc though - it looks so much cleaner. Yes.

@argyleink
Copy link
Owner

a) my lack of imagination how these primitives should be used shouldn't stop others from doing it
b) it wouldn't "burden" the core lib since it would be a prop pack

yep, very true. however, I do need at least one or two use cases in order to verify the negative value strategy we go with, is actually useful.

like here, you show not just inverting values, but inverting the parameters:

--size-fluid-1: clamp(0.5rem, 1vw, 1rem); /* positive */
--size-fluid-1-: clamp(-1rem, -1vi, -0.5rem); /* negative */

that's interesting!

and here I suggest inverting the result of the value it's a compliment for:

--size-fluid-1-: calc(var(--size-fluid-1) * -1);

🤷🏻

I don't think these two strategies produce the same values in all situations, and I don't know which one is right. I think we need to know what we're solving for, to make sure these vars behave like we want them to.

best idea I can come up with is some negative margin to offset the padding or margin of a container?

@felix-bohlin
Copy link
Author

felix-bohlin commented Dec 20, 2024

Regardless of how interesting it could be to invert all values I think your inversion is more what you'd expect from a negative size-fluid - it's way more reasonable. The use-cases won't differ much between the two approaches as far as I can tell.

This is a demo I made earlier and it's all negative margins and pull quotes and break out stuff. Can't think of cooler stuff than that 😅 I've added both approaches there just for a quick comparison.

Pushed a new commit based on your calc() approach and also re-used the existing sizes in the negative sizes JS solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants